{$CLEO .cs}
{$USE CLEO+}
{$USE ini}

0000: NOP

script_name "WD UZI"

// By ArtemQa146

if
    0AA2: 31@ = load_dynamic_library "CLEO+.cleo"
then
    if
        0AA4: 30@ = get_dynamic_library_procedure "GetCleoPlusVersion" library 31@
    then
        0AA7: call_function_return 30@ num_params 0 pop 0 29@
        if
            not 29@ >= 0x1020000
        then
            0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
            0AA3: free_dynamic_library 31@
            0A93: terminate_this_custom_script
        end
        0AA3: free_dynamic_library 31@
    end
else
    0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
    0AA3: free_dynamic_library 31@
    0A93: terminate_this_custom_script
end

if
    0E2D: is_game_first_start
then
    0F00: load_special_model_dff "tec9\tec9_S" txd "tec9\tec9" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "tec9_S"
    0F00: load_special_model_dff "tec9\tec9_R" txd "tec9\tec9" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "tec9_R"
    0F00: load_special_model_dff "tec9\tec9_O" txd "tec9\tec9" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "tec9_O"
    0F00: load_special_model_dff "micro_uzi\micro_uzi_S" txd "micro_uzi\micro_uzi" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "micro_uzi_S"
    0F00: load_special_model_dff "micro_uzi\micro_uzi_R" txd "micro_uzi\micro_uzi" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "micro_uzi_R"
    0F00: load_special_model_dff "micro_uzi\micro_uzi_O" txd "micro_uzi\micro_uzi" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "micro_uzi_O"
end

const
    tec9_s = 31@
    tec9_r = 30@
    tec9_o = 29@
    tec9_Clip_Model = 28@
    tec9_Clip_X = 27@
    tec9_Clip_Y = 26@
    tec9_Clip_Z = 25@
    tec9_s2 = 24@
    tec9_r2 = 23@
    tec9_o2 = 22@

    uzi_s = 21@
    uzi_r = 20@
    uzi_o = 19@
    uzi_Clip_Model = 18@
    uzi_Clip_X = 17@
    uzi_Clip_Y = 16@
    uzi_Clip_Z = 15@
    uzi_s2 = 14@
    uzi_r2 = 13@
    uzi_o2 = 12@
end

repeat
wait 0
until player.Defined(0)

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "tec9_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale tec9_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 0.03 0.03 0 rotation 0 180.0 180.0 scale tec9_s2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: tec9_Clip_X = get_float_from_ini_file "cleo\tec9.ini" section "settings" key "Clip X"
0AF2: tec9_Clip_Y = get_float_from_ini_file "cleo\tec9.ini" section "settings" key "Clip Y"
0AF2: tec9_Clip_Z = get_float_from_ini_file "cleo\tec9.ini" section "settings" key "Clip Z"
0AF0: tec9_Clip_Model = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "tec9_R"
0F02:  $PLAYER_ACTOR special_model tec9_Clip_Model bone 24 offset tec9_Clip_X tec9_Clip_Y tec9_Clip_Z rotation 0 0 0 scale tec9_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF2: 1@ = get_float_from_ini_file "cleo\tec9.ini" section "settings" key "Clip X2"
0AF2: 2@ = get_float_from_ini_file "cleo\tec9.ini" section "settings" key "Clip Y2"
0AF2: 3@ = get_float_from_ini_file "cleo\tec9.ini" section "settings" key "Clip Z2"
0F02:  $PLAYER_ACTOR special_model tec9_Clip_Model bone 34 offset 1@ 2@ 3@ rotation 0 180.0 180.0 scale tec9_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "tec9_O"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale tec9_o // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 0.03 0.03 0 rotation 0 180.0 180.0 scale tec9_o2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors


0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "micro_uzi_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale uzi_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 0.03 0.03 0 rotation 0 180.0 180.0 scale uzi_s2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: uzi_Clip_X = get_float_from_ini_file "cleo\micro_uzi.ini" section "settings" key "Clip X"
0AF2: uzi_Clip_y = get_float_from_ini_file "cleo\micro_uzi.ini" section "settings" key "Clip Y"
0AF2: uzi_Clip_z = get_float_from_ini_file "cleo\micro_uzi.ini" section "settings" key "Clip Z"
0AF0: uzi_Clip_Model = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "micro_uzi_R"
0F02:  $PLAYER_ACTOR special_model uzi_Clip_Model bone 24 offset uzi_Clip_X uzi_Clip_y uzi_Clip_z rotation 0 0 0 scale uzi_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF2: 1@ = get_float_from_ini_file "cleo\micro_uzi.ini" section "settings" key "Clip X2"
0AF2: 2@ = get_float_from_ini_file "cleo\micro_uzi.ini" section "settings" key "Clip Y2"
0AF2: 3@ = get_float_from_ini_file "cleo\micro_uzi.ini" section "settings" key "Clip Z2"
0F02:  $PLAYER_ACTOR special_model uzi_Clip_Model bone 34 offset 1@ 2@ 3@ rotation 0 180.0 180.0 scale uzi_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "micro_uzi_O"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale uzi_o // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 0.03 0.03 0 rotation 0 180.0 180.0 scale uzi_o2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors


0E31: set_render_object_visible tec9_s 0
0E31: set_render_object_visible tec9_s2 0
0E31: set_render_object_visible tec9_o 0
0E31: set_render_object_visible tec9_o2 0
0E31: set_render_object_visible tec9_r 0
0E31: set_render_object_visible tec9_r2 0

0E31: set_render_object_visible uzi_s 0
0E31: set_render_object_visible uzi_s2 0
0E31: set_render_object_visible uzi_o 0
0E31: set_render_object_visible uzi_o2 0
0E31: set_render_object_visible uzi_r 0
0E31: set_render_object_visible uzi_r2 0



while true
wait 0
    if
        player.Defined(0)
    then
        if
            actor.Driving($PLAYER_ACTOR)
        then
            continue
        end

        0AAA: 1@ = get_script_struct_named 'Tec9'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 32
            1@ == 0
        then
            0A92: stream_custom_script "Tec9.qa" tec9_s tec9_r tec9_o tec9_Clip_Model tec9_Clip_X tec9_Clip_Y tec9_Clip_Z tec9_s2 tec9_r2 tec9_o2
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Tec9'
            until 1@ > 0
            continue
        end

        0AAA: 1@ = get_script_struct_named 'MicUzi'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 28
            1@ == 0
        then
            0A92: stream_custom_script "Micro_Uzi.qa" uzi_s uzi_r uzi_o uzi_Clip_Model uzi_Clip_X uzi_Clip_y uzi_Clip_z uzi_s2 uzi_r2 uzi_o2
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'MicUzi'
            until 1@ > 0
            continue
        end
        

    end
end